package com.hzdaba.aiapi.controller;

import com.hzdaba.aiapi.dto.CustomerLoginDto;
import com.hzdaba.aiapi.service.AiCustomerService;
import com.hzdaba.aiapi.vo.CustomerLoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理用户相关请求
 *
 * @author 刘逸晖
 */
@RestController
@RequestMapping("/api/customer")
public class AiCustomerController {

    /**
     * 处理用户相关业务
     */
    @Autowired
    private AiCustomerService aiCustomerService;

    @PostMapping("/login")
    public CustomerLoginVo login(@RequestBody CustomerLoginDto customerLoginDto) {
        String token = this.aiCustomerService.login(customerLoginDto);
        CustomerLoginVo customerLoginVo = new CustomerLoginVo();

        customerLoginVo.setResult(true);
        customerLoginVo.setReason("恭喜，登录成功");
        customerLoginVo.setToken(token);

        return customerLoginVo;
    }

}
